<template>
  <div>
    <div style="display: flex; justify-content: flex-start">
      <el-input
        placeholder="通过操作者用户名搜索..."
        prefix-icon="el-icon-search"
        v-model="keywords"
        style="width: 400px"
        size="medium "
        clearable
      >
      </el-input>
      <el-button
        type="primary"
        icon="el-icon-search"
        size="mini"
        style="margin-left: 3px"
        @click="searchClick(keywords)"
        >搜索
      </el-button>
    </div>
    <el-table :data="tableData" style="width: 100%" v-loading="loading">
      <el-table-column label="IP" width="180">
        <template slot-scope="scope"
          ><span style="color: #409eff; cursor: pointer">{{
            scope.row.ip
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作时间" width="180">
        <template slot-scope="scope"
          ><span style="color: #409eff; cursor: pointer">{{
            scope.row.opertime
          }}</span>
        </template>
      </el-table-column>
      <el-table-column  label="操作账号" width="180">
        <template slot-scope="scope"
          ><span style="color: #409eff; cursor: pointer">{{
            scope.row.opername
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作内容" width="180">
        <template slot-scope="scope"
          ><span style="color: #409eff; cursor: pointer">{{
            scope.row.ddesc
          }}</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage1"
      :page-sizes="[5, 10, 15]"
      :page-size="5"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { logs } from "@/api/apis";
export default {
  data() {
    return {
      currentPage1: 1,
      keywords: "",
      tableData: [],
      loading: false,
      pageSize: 5,
      total: 1,
    };
  },
  created() {
    this.loading = true;
    this.refresh();
  },
  methods: {

    handleSizeChange(val) {
        // console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.refresh(this.pageSize);
    },
    handleCurrentChange(val) {
      //   console.log(`当前页: ${val}`);
      this.currentPage1 = val;
      this.refresh(this.currentPage1);
    },
    refresh() {
        
      logs(this.pageSize,this.currentPage1,this.keywords).then(
        (res) => {
        //   console.log(res);
          this.tableData = res.data.data.records;
          this.total = res.data.data.total;
          //   console.log(this.total);
          this.loading = false;
        }
      );
    },
    searchClick(keywords) {
      this.keywords = keywords;
    //   console.log(this.keywords)
      this.refresh(this.keywords);
    },

  },
};
</script>

<style scoped>

</style>